package com.itheima.reggie.mapper;

import com.itheima.reggie.entity.Category;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

public interface CategoryMapper {

    @Insert("insert into category values(null,#{type},#{name},#{sort},#{createTime},#{updateTime},#{createUser},#{updateUser})")
    void add(Category category);

    @Select("select * from category")
    List<Category> find();

    @Delete("delete from category where id = #{id}")
    void delete(@Param("id") Long id);

    @Update("update category set name=#{name},sort=#{sort},update_time=#{updateTime},update_user=#{updateUser} where id = #{id}")
    void update(Category category);


    List<Category> list(@Param("type") Integer type);

    @Select("select * from category where id = #{id}")
    Category findById(Long categoryId);
}
